﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class b1
{
    static void Main()
    {
        Console.WriteLine("{0,-10} {1,-10} {2,-30} {3,-30}", "Type", "Bytes", "Min Value", "Max Value");
        Console.WriteLine(new string('-', 85));

        PrintTypeInfo<sbyte>("sbyte");
        PrintTypeInfo<byte>("byte");
        PrintTypeInfo<short>("short");
        PrintTypeInfo<ushort>("ushort");
        PrintTypeInfo<int>("int");
        PrintTypeInfo<uint>("uint");
        PrintTypeInfo<long>("long");
        PrintTypeInfo<ulong>("ulong");
        PrintTypeInfo<float>("float");
        PrintTypeInfo<double>("double");
        PrintTypeInfo<decimal>("decimal");

        Console.ReadLine();
    }

    static void PrintTypeInfo<T>(string typeName) where T : struct
    {
        int size = System.Runtime.InteropServices.Marshal.SizeOf<T>();
        string minValue = typeof(T).IsPrimitive ? Convert.ToString(GetMinValue<T>()) : "N/A";
        string maxValue = typeof(T).IsPrimitive ? Convert.ToString(GetMaxValue<T>()) : "N/A";

        Console.WriteLine("{0,-10} {1,-10} {2,-30} {3,-30}", typeName, size, minValue, maxValue);
    }

    static object GetMinValue<T>() where T : struct
    {
        return typeof(T).GetField("MinValue")?.GetValue(null) ?? "N/A";
    }

    static object GetMaxValue<T>() where T : struct
    {
        return typeof(T).GetField("MaxValue")?.GetValue(null) ?? "N/A";
    }
}

